import { createRouter, createWebHashHistory } from 'vue-router'
import ShowPage from '../views/ShowPage.vue'
import Page1 from '../views/Page1/Page1.vue'
import Home from '../views/Home.vue'

const routes = [
  {
    path: '/',
    component:ShowPage,
    meta:{
      title:'欢迎'
    }
  },{
    path: '/login',
    component:()=>import('../views/Login.vue'),
    meta:{
      title:'登录'
    }
  },{
    path: '/home', 
    component:Home,
    meta:{
      title:'主页'
    },
    children:[
      {
        path:'',
        component:Page1
      },{
        path:'page1',
        component:Page1
      },{
        path:'page2',
        component:()=>import('../views/Page2/Page2.vue'),
        children:[
          {
            path:'',
            component:()=>import('../views/Page2/PageItem1.vue'),
          },
          {
            path:'item1',
            component:()=>import('../views/Page2/PageItem1.vue'),
          },
          {
            path:'item2',
            component:()=>import('../views/Page2/PageItem2.vue'),
          },
          {
            path:'item3',
            component:()=>import('../views/Page2/PageItem3.vue'),
          },
          {
            path:'item4',
            component:()=>import('../views/Page2/PageItem4.vue'),
          },
          {
            path:'item5',
            component:()=>import('../views/Page2/PageItem5.vue'),
          }
        ]
      },{
        path:'page3',
        component:()=>import('../views/Page3/Page3.vue')
      },{
        path:'page4',
        component:()=>import('../views/Page4/Page4.vue')
      }
    ]
  },{
    path: '/detail',
    component:()=>import('../views/Page1/PhotoDetail.vue'),
    meta:{
      title:'具体内容'
    }
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})
router.beforeEach((to,from,next)=>{
  document.title=to.meta.title
  next()
})

export default router
